package classesInterface;

import classesBancodeDados.FichaAtendPsiqUrgencia;
import classesBancodeDados.Paciente;
import classesBancodeDados.Pessoa;
import classesBancodeDados.Responsavel;
import classesJpa.FichaAtendPsiqUrgenciaJpaController;
import classesJpa.PacienteJpaController;
import classesJpa.exceptions.NonexistentEntityException;
import classesMiolo.DataHorario;
import classesMiolo.Formatador;
import classesMiolo.MapasAtendPsiqUrgencia;
import classesMiolo.MapasPaciente;
import classesMiolo.ReverseMapper;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class TelaFichaAtendPsiqUrgencia extends javax.swing.JFrame {

    /**
     * Creates new form AtendPsiqUrgencia
     */
    private TelaFichaAtendPsiqUrgencia() {
        initComponents();
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }
    
    public static TelaFichaAtendPsiqUrgencia getInstance(){
        if(instance == null) instance = new TelaFichaAtendPsiqUrgencia();
        return instance;
    }
    
    public void turnEditable(boolean editable){
        this.editable = editable;
        botaoSalvar.setEnabled(editable);
        this.campoAtendido.setEditable(editable);
        this.campoData.setEditable(editable);
        this.campoDocResponsavel.setEditable(false);
        this.campoEndereco.setEditable(false);
        this.campoFC.setEditable(editable);
        this.campoFR.setEditable(editable);
        this.campoGlicemia.setEditable(editable);
        this.campoHistoria.setEditable(editable);
        this.campoHora.setEditable(editable);
        this.campoIdade.setEditable(false);
        this.campoIdentidade.setEditable(false);
        this.campoMae.setEditable(false);
        this.campoNascimento.setEditable(false);
        this.campoNaturalidade.setEditable(false);
        this.campoNome.setEditable(false);
        this.campoOcupacao.setEditable(editable);
        this.campoPA.setEditable(editable);
        this.campoPai.setEditable(false);
        this.campoPeso.setEditable(editable);
        this.campoProcedencia.setEditable(editable);
        this.campoProntuario.setEditable(false);
        this.campoRecepcionista.setEditable(false);
        this.campoResponsavel.setEditable(false);
        this.campoTelResponsavel.setEditable(false);
        this.checkAgitado.setEnabled(editable);
        this.checkChocado.setEnabled(editable);
        this.checkConvulsao.setEnabled(editable);
        this.checkDispneia.setEnabled(editable);
        this.checkHemorragia.setEnabled(editable);
        this.checkPoli.setEnabled(editable);
        this.comboCondicao.setEnabled(editable);
        this.comboEscolaridade.setEnabled(false);
        this.comboSexo.setEnabled(false);
        this.comboTransporte.setEnabled(editable);
    }
    
    public void limpaCampos(){
        this.campoAtendido.setText("");
        this.campoData.setText("");
        this.campoDocResponsavel.setText("");
        this.campoEndereco.setText("");
        this.campoFC.setText("");
        this.campoFR.setText("");
        this.campoGlicemia.setText("");
        this.campoHistoria.setText("");
        this.campoHora.setText("");
        this.campoIdade.setText("");
        this.campoIdentidade.setText("");
        this.campoMae.setText("");
        this.campoNascimento.setText("");
        this.campoNaturalidade.setText("");
        this.campoNome.setText("");
        this.campoOcupacao.setText("");
        this.campoPA.setText("");
        this.campoPai.setText("");
        this.campoPeso.setText("");
        this.campoProcedencia.setText("");
        this.campoProntuario.setText("");
        this.campoRecepcionista.setText("");
        this.campoResponsavel.setText("");
        this.campoTelResponsavel.setText("");
        this.checkAgitado.setSelected(false);
        this.checkChocado.setSelected(false);
        this.checkConvulsao.setSelected(false);
        this.checkDispneia.setSelected(false);
        this.checkHemorragia.setSelected(false);
        this.checkPoli.setSelected(false);
        this.comboCondicao.setSelectedIndex(0);
        this.comboEscolaridade.setSelectedIndex(0);
        this.comboSexo.setSelectedIndex(0);
        this.comboTransporte.setSelectedIndex(0);
    }
    
    public void preencherCampos(Paciente p, Responsavel r, Pessoa recep, FichaAtendPsiqUrgencia ficha){
        MapasPaciente mapaP = MapasPaciente.getInstance();
        MapasAtendPsiqUrgencia mapaF = MapasAtendPsiqUrgencia.getInstance();
        this.campoAtendido.setText(ficha.getnAtend() + "");
        this.campoData.setText(ficha.getData());
        this.campoDocResponsavel.setText(r.getCpf());
        this.campoEndereco.setText(p.getEndLogradouro() + ", " + p.getEndNumero() + ", " + p.getEndBairro());
        this.campoFC.setText(ficha.getFreqResp() + "");
        this.campoFR.setText(ficha.getFreqCard() + "");
        this.campoGlicemia.setText(ficha.getGlicemia() + "");
        this.campoHistoria.setText(ficha.getHistoria());
        this.campoHora.setText(ficha.getHora());
        this.campoIdade.setText(DataHorario.calculaIdade(p.getDataDeNascimento()) + "");
        this.campoIdentidade.setText(p.getIdentidade());
        this.campoMae.setText(p.getNomeMae());
        this.campoNascimento.setText(p.getDataDeNascimento());
        this.campoNaturalidade.setText(p.getNaturalidade());
        this.campoNome.setText(p.getNome() + p.getSobrenome());
        this.campoOcupacao.setText(p.getProfissao());
        this.campoPA.setText(ficha.getPresArt());
        this.campoPai.setText(p.getNomePai());
        this.campoPeso.setText(ficha.getPeso() + "");
        this.campoProcedencia.setText(ficha.getProcedencia());
        this.campoProntuario.setText(ficha.getNumeroProntuario());
        this.campoRecepcionista.setText(recep.getNome());
        this.campoResponsavel.setText(r.getNome());
        this.campoTelResponsavel.setText(r.getTelefone());
        this.checkAgitado.setSelected(ficha.isAgitado());
        this.checkChocado.setSelected(ficha.isChocado());
        this.checkConvulsao.setSelected(ficha.isConvulsao());
        this.checkDispneia.setSelected(ficha.isDispneia());
        this.checkHemorragia.setSelected(ficha.isHemorragia());
        this.checkPoli.setSelected(ficha.isPolitraumatizado());
        this.comboCondicao.setSelectedItem(ReverseMapper.getKeyFromValue(mapaF.getCondicao(), ficha.getCondicao()));
        this.comboEscolaridade.setSelectedItem(ReverseMapper.getKeyFromValue(mapaP.getEscolaridade(), p.getEscolaridade()));
        this.comboSexo.setSelectedItem(ReverseMapper.getKeyFromValue(mapaP.getSexo(), p.getSexo()));
        this.comboTransporte.setSelectedItem(ReverseMapper.getKeyFromValue(mapaF.getTransporte(), ficha.getTransporte()));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollBar1 = new javax.swing.JScrollBar();
        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        campoProntuario = new javax.swing.JTextField();
        campoData = new javax.swing.JFormattedTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        campoHora = new javax.swing.JFormattedTextField();
        jLabel6 = new javax.swing.JLabel();
        campoNome = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        campoAtendido = new javax.swing.JTextField();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel8 = new javax.swing.JLabel();
        comboSexo = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        campoNaturalidade = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        campoNascimento = new javax.swing.JFormattedTextField();
        jLabel12 = new javax.swing.JLabel();
        campoIdade = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        campoEndereco = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        cidade = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        uf = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        campoPai = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        campoMae = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        campoOcupacao = new javax.swing.JTextField();
        jSeparator3 = new javax.swing.JSeparator();
        jLabel21 = new javax.swing.JLabel();
        campoResponsavel = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        campoTelResponsavel = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        campoDocResponsavel = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        campoProcedencia = new javax.swing.JTextField();
        jLabel25 = new javax.swing.JLabel();
        comboTransporte = new javax.swing.JComboBox();
        jSeparator4 = new javax.swing.JSeparator();
        botaoSalvar = new javax.swing.JButton();
        campoRecepcionista = new javax.swing.JTextField();
        campoIdentidade = new javax.swing.JTextField();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        comboCondicao = new javax.swing.JComboBox();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        campoHistoria = new javax.swing.JTextArea();
        jButton2 = new javax.swing.JButton();
        campoPA = new javax.swing.JTextField();
        campoPeso = new javax.swing.JTextField();
        campoGlicemia = new javax.swing.JTextField();
        checkPoli = new javax.swing.JCheckBox();
        checkAgitado = new javax.swing.JCheckBox();
        checkConvulsao = new javax.swing.JCheckBox();
        checkHemorragia = new javax.swing.JCheckBox();
        checkChocado = new javax.swing.JCheckBox();
        checkDispneia = new javax.swing.JCheckBox();
        comboEscolaridade = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        campoFR = new javax.swing.JTextField();
        campoFC = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Andalus", 1, 14)); // NOI18N
        jLabel1.setText("Ficha de Atendimento Psiquiátrico de Urgência");

        jLabel2.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel2.setText("Ficha nº");

        jLabel3.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel3.setText("Data:");

        campoProntuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoProntuarioActionPerformed(evt);
            }
        });

        campoData.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoDataActionPerformed(evt);
            }
        });
        campoData.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                campoDataKeyPressed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel4.setText("Recepcionista:");

        jLabel5.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel5.setText("Hora:");

        campoHora.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoHoraActionPerformed(evt);
            }
        });
        campoHora.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                campoHoraKeyPressed(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel6.setText("Nome:");

        campoNome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoNomeActionPerformed(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel7.setText("Número de vezes atendido:");

        jLabel8.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel8.setText("Sexo:");

        comboSexo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Masculino", "Feminino" }));

        jLabel9.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel9.setText("Identidade:");

        jLabel10.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel10.setText("Naturalidade:");

        jLabel11.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel11.setText("Data de Nascimento:");

        campoNascimento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoNascimentoActionPerformed(evt);
            }
        });
        campoNascimento.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                campoNascimentoKeyPressed(evt);
            }
        });

        jLabel12.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel12.setText("Idade:");

        campoIdade.setEditable(false);

        jLabel13.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel13.setText("Endereço:");

        jLabel15.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel15.setText("Cidade:");

        jLabel16.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel16.setText("UF:");

        jLabel17.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel17.setText("Pai:");

        campoPai.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoPaiActionPerformed(evt);
            }
        });

        jLabel18.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel18.setText("Mãe:");

        campoMae.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoMaeActionPerformed(evt);
            }
        });

        jLabel19.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel19.setText("Ocupação:");

        jLabel20.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel20.setText("Escolaridade:");

        jLabel21.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel21.setText("Responsável:");

        campoResponsavel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoResponsavelActionPerformed(evt);
            }
        });

        jLabel22.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel22.setText("Telefone:");

        campoTelResponsavel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoTelResponsavelActionPerformed(evt);
            }
        });
        campoTelResponsavel.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                campoTelResponsavelKeyPressed(evt);
            }
        });

        jLabel23.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel23.setText("Documento:");

        jLabel24.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel24.setText("Procedência:");

        campoProcedencia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoProcedenciaActionPerformed(evt);
            }
        });

        jLabel25.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel25.setText("Transporte utilizado:");

        comboTransporte.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione...", "SAMU", "Próprio", "Ambulância", "Táxi", "Polícia", "Outros" }));
        comboTransporte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboTransporteActionPerformed(evt);
            }
        });

        botaoSalvar.setText("Salvar");
        botaoSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoSalvarActionPerformed(evt);
            }
        });

        jLabel26.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel26.setText("Preconsulta Condições do Paciente ao ser Atendido:");

        jLabel27.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel27.setText("PA:");

        comboCondicao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Aparentemente Bem", "Regular", "Grave" }));

        jLabel28.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel28.setText("Peso:");

        jLabel29.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel29.setText("Glicemia:");

        jLabel30.setFont(new java.awt.Font("Calibri Light", 1, 11)); // NOI18N
        jLabel30.setText("Historia - Exame Físico - (Hora do Atendimento)");

        campoHistoria.setColumns(20);
        campoHistoria.setRows(5);
        jScrollPane1.setViewportView(campoHistoria);

        jButton2.setText("Próximo >");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        checkPoli.setText("Politraumatizado");

        checkAgitado.setText("Agitado");

        checkConvulsao.setText("Convulsão");

        checkHemorragia.setText("Com Hemorragia");

        checkChocado.setText("Chocado");

        checkDispneia.setText("Dispneia");

        comboEscolaridade.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Nenhuma", "Fundamental Incompleto", "Fundamental Completo", "Médio Incompleto", "Médio Completo", "Superior Incompleto", "Superior Completo", "Pós-Graduado" }));

        jLabel14.setText("FR:");

        jLabel31.setText("FC:");

        jButton3.setText("Cancela");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jSeparator3)
                    .addComponent(jSeparator4)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(campoProntuario, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(campoData)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(campoHora, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(campoRecepcionista, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(campoNome))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jLabel24)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoProcedencia))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jLabel21)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoResponsavel, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel25)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboTransporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel22)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoTelResponsavel, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel23)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoDocResponsavel, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoNascimento))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoAtendido, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel8)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(comboSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoIdentidade, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoNaturalidade))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoIdade, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel19)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoOcupacao)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel20)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboEscolaridade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jButton3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(botaoSalvar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton2))))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cidade, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(uf, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(campoEndereco))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel26)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboCondicao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel27)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoPA, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel28)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoPeso, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel29)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoGlicemia))
                            .addComponent(jLabel30))
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel14)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoFR))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel31)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoFC, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(checkHemorragia, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(checkPoli, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(checkChocado)
                            .addComponent(checkAgitado))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(checkDispneia)
                            .addComponent(checkConvulsao)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(campoPai, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(90, 90, 90)
                        .addComponent(jLabel18)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(campoMae)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(campoData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel5)
                        .addComponent(campoHora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel4)
                        .addComponent(campoRecepcionista, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel3))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(campoProntuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(campoAtendido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(comboSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(campoIdentidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(campoNaturalidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(campoNascimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(campoIdade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19)
                    .addComponent(campoOcupacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel20)
                    .addComponent(comboEscolaridade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(cidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16)
                    .addComponent(uf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13)
                    .addComponent(campoEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(campoPai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18)
                    .addComponent(campoMae, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(campoResponsavel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel22)
                    .addComponent(campoTelResponsavel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel23)
                    .addComponent(campoDocResponsavel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel24)
                    .addComponent(campoProcedencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25)
                    .addComponent(comboTransporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel26)
                    .addComponent(comboCondicao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(checkPoli)
                    .addComponent(checkAgitado)
                    .addComponent(checkConvulsao)
                    .addComponent(jLabel14)
                    .addComponent(campoFR, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel27)
                    .addComponent(jLabel28)
                    .addComponent(jLabel29)
                    .addComponent(campoPA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(campoPeso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(campoGlicemia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(checkHemorragia)
                    .addComponent(checkChocado)
                    .addComponent(checkDispneia)
                    .addComponent(jLabel31)
                    .addComponent(campoFC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel30)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botaoSalvar)
                    .addComponent(jButton2)
                    .addComponent(jButton3))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void campoProntuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoProntuarioActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_campoProntuarioActionPerformed

    private void campoDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoDataActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_campoDataActionPerformed

    private void campoHoraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoHoraActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_campoHoraActionPerformed

    private void campoNomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoNomeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_campoNomeActionPerformed

    private void campoNascimentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoNascimentoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_campoNascimentoActionPerformed

    private void campoPaiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoPaiActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_campoPaiActionPerformed

    private void campoMaeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoMaeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_campoMaeActionPerformed

    private void campoResponsavelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoResponsavelActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_campoResponsavelActionPerformed

    private void campoProcedenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoProcedenciaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_campoProcedenciaActionPerformed

    private void comboTransporteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboTransporteActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_comboTransporteActionPerformed

    private void campoDataKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoDataKeyPressed
        if(evt.getKeyChar() != '\b'){
            campoData.setText(Formatador.formataData(campoData.getText()));
        }
    }//GEN-LAST:event_campoDataKeyPressed

    private void campoNascimentoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoNascimentoKeyPressed
        if(evt.getKeyChar() != '\b'){
            campoNascimento.setText(Formatador.formataData(campoNascimento.getText()));
        }
    }//GEN-LAST:event_campoNascimentoKeyPressed

    private void campoHoraKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoHoraKeyPressed
        if(evt.getKeyChar() != '\b'){
            campoHora.setText(Formatador.formataHora(campoHora.getText()));
        }
    }//GEN-LAST:event_campoHoraKeyPressed

    private void botaoSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoSalvarActionPerformed
        salvar();
    }//GEN-LAST:event_botaoSalvarActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        TelaFichaAtendPsiqUrgencia2.getInstance().setFicha(ficha);
        PacienteJpaController jpa = new PacienteJpaController();
        TelaFichaAtendPsiqUrgencia2.getInstance().preencherCampos(jpa.findPacienteSus(ficha.getSus()), ficha);
        TelaFichaAtendPsiqUrgencia2.getInstance().turnEditable(editable);
        setVisible(false);
        TelaFichaAtendPsiqUrgencia2.getInstance().setVisible(true);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void campoTelResponsavelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoTelResponsavelActionPerformed

    }//GEN-LAST:event_campoTelResponsavelActionPerformed

    private void campoTelResponsavelKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoTelResponsavelKeyPressed
        if(evt.getKeyChar() != '\b'){
            campoTelResponsavel.setText(Formatador.formataTelefone(campoTelResponsavel.getText()));
        }
    }//GEN-LAST:event_campoTelResponsavelKeyPressed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        TelaFichaAtendPsiqUrgencia.getInstance().limpaCampos();
        TelaFichaAtendPsiqUrgencia2.getInstance().limpaCampos();
        setVisible(false);        
    }//GEN-LAST:event_jButton3ActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        TelaFichaAtendPsiqUrgencia.getInstance().limpaCampos();
        TelaFichaAtendPsiqUrgencia2.getInstance().limpaCampos();
        setVisible(false);   
    }//GEN-LAST:event_formWindowClosing

    public void salvar(){
        MapasAtendPsiqUrgencia mapa = MapasAtendPsiqUrgencia.getInstance();
        ficha.setData(campoData.getText());
        ficha.setHora(campoHora.getText());
        ficha.setnAtend(Integer.parseInt(campoAtendido.getText()));
        ficha.setProcedencia(this.campoProcedencia.getText());
        ficha.setTransporte(mapa.getTransporte().get(comboTransporte.getSelectedItem()));
        ficha.setCondicao(mapa.getCondicao().get(comboCondicao.getSelectedItem()));
        ficha.setPresArt(campoPA.getText());
        ficha.setFreqResp(Double.parseDouble(campoFR.getText()));
        ficha.setFreqCard(Double.parseDouble(campoFC.getText()));
        ficha.setPeso(Double.parseDouble(campoPeso.getText()));
        ficha.setGlicemia(Double.parseDouble(campoGlicemia.getText()));
        ficha.setAgitado(checkAgitado.isSelected());
        ficha.setChocado(checkChocado.isSelected());
        ficha.setConvulsao(checkConvulsao.isSelected());
        ficha.setDispneia(checkDispneia.isSelected());
        ficha.setHemorragia(checkHemorragia.isSelected());
        ficha.setPolitraumatizado(checkPoli.isSelected());
        ficha.setHistoria(campoHistoria.getText());
        FichaAtendPsiqUrgenciaJpaController apuc = new FichaAtendPsiqUrgenciaJpaController();
        try{
            apuc.edit(ficha);
        }catch(NonexistentEntityException e){
            JOptionPane.showMessageDialog(null, "Ficha não encontrada.");
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Erro na comunicação com o Banco de Dados.");
        }        
    }

    public boolean isEditable() {
        return editable;
    }

    public void setEditable(boolean editable) {
        this.editable = editable;
    }

    
    public FichaAtendPsiqUrgencia getFicha() {
        return ficha;
    }

    public void setFicha(FichaAtendPsiqUrgencia ficha) {
        this.ficha = ficha;
    }    
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TelaFichaAtendPsiqUrgencia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TelaFichaAtendPsiqUrgencia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TelaFichaAtendPsiqUrgencia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TelaFichaAtendPsiqUrgencia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                TelaFichaAtendPsiqUrgencia.getInstance().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoSalvar;
    private javax.swing.JTextField campoAtendido;
    private javax.swing.JFormattedTextField campoData;
    private javax.swing.JTextField campoDocResponsavel;
    private javax.swing.JTextField campoEndereco;
    private javax.swing.JTextField campoFC;
    private javax.swing.JTextField campoFR;
    private javax.swing.JTextField campoGlicemia;
    private javax.swing.JTextArea campoHistoria;
    private javax.swing.JFormattedTextField campoHora;
    private javax.swing.JTextField campoIdade;
    private javax.swing.JTextField campoIdentidade;
    private javax.swing.JTextField campoMae;
    private javax.swing.JFormattedTextField campoNascimento;
    private javax.swing.JTextField campoNaturalidade;
    private javax.swing.JTextField campoNome;
    private javax.swing.JTextField campoOcupacao;
    private javax.swing.JTextField campoPA;
    private javax.swing.JTextField campoPai;
    private javax.swing.JTextField campoPeso;
    private javax.swing.JTextField campoProcedencia;
    private javax.swing.JTextField campoProntuario;
    private javax.swing.JTextField campoRecepcionista;
    private javax.swing.JTextField campoResponsavel;
    private javax.swing.JTextField campoTelResponsavel;
    private javax.swing.JCheckBox checkAgitado;
    private javax.swing.JCheckBox checkChocado;
    private javax.swing.JCheckBox checkConvulsao;
    private javax.swing.JCheckBox checkDispneia;
    private javax.swing.JCheckBox checkHemorragia;
    private javax.swing.JCheckBox checkPoli;
    private javax.swing.JTextField cidade;
    private javax.swing.JComboBox comboCondicao;
    private javax.swing.JComboBox comboEscolaridade;
    private javax.swing.JComboBox comboSexo;
    private javax.swing.JComboBox comboTransporte;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollBar jScrollBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JTextField uf;
    // End of variables declaration//GEN-END:variables
    private static TelaFichaAtendPsiqUrgencia instance;
    private FichaAtendPsiqUrgencia ficha;
    private boolean editable;
}
